const http = require('http')
const {getCachedMessage, redisConnect} = require('./cache.js')

async function run() {
    const client = await redisConnect()
    http.createServer(async function(req, resp) {
        if (req.url === '/') {
            const msg = await getCachedMessage(client)
            resp.writeHead(200)
            resp.end(msg)
        }
    }).listen(3000)
}

run().catch(err => console.log(err))